package reflex;

import java.lang.reflect.Field;

public class GetField {
    public static void main(String[] args) {
        try {
            Class<?> aClass = Class.forName("reflex.Student");
//            Field字段
            Field[] fields = aClass.getDeclaredFields();

            System.out.println(fields.length);
            for (Field f:fields
                 ) {
                System.out.println(f.getName());
            }
//            Object o = aClass.getConstructor().newInstance();
//            Field address = aClass.getDeclaredField("address");
//            System.out.println(address.getName());
//            address.setAccessible(true);
//            address.set(o, "12345");
//            System.out.println(address.get(o));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
